#include <iostream>
using std::cout;
using std::endl;

void test0(){
    int num = 100;
    int num2 = 200;

    //定义引用绑定一个已存在的变量
    //有点像指针
    /* int * p = &num; */

    int & ref = num;
    ref += 1;
    cout << num << endl;
    cout << &num << endl;
    //指针变量本身的地址与其指向的地址不一样
    //对于引用取址，返回的一定是其绑定的变量本体的地址
    cout << &ref << endl;
    cout << &num2 << endl;
    
    //这里不是更改绑定，而是赋值操作
    ref = num2;
    cout << num << endl;
    cout << &num << endl;
    cout << &ref << endl;
    cout << &num2 << endl;

    /* int & ref2 = num; */
    /* int & ref3 = ref2; */
}

int main(void){
    test0();
    return 0;
}
